package com.fingard.dsp.bank.reqrespobj.elecbillquery;

import com.fingard.dsp.bank.reqrespobj.ReqRespHeader;
import com.fingard.dsp.bank.reqrespobj.RetAtsBase;
import com.fingard.dsp.bank.reqrespobj.elecbillquery.detail.RetAtsB001OperBillQryDetail;
import com.fingard.text.StringHelper;
import com.fingard.xml.XmlTextWriter;

/**
 * Created by dell on 2017/10/30.
 */
public class RetAtsB001OperBillQry extends RetAtsBase {

    public String respCode;
    public String respInfo;


    public RetAtsB001OperBillQry(ReqRespHeader p_header) {
        retHeader = p_header;
        retXmlWriter = new XmlTextWriter();//用于输出返回ATS的XML报文
    }


    public void writeBefore() {
        writeStart();//写返回ATS的统一头部信息
        retXmlWriter.writeElementString("RespCode", respCode);
        retXmlWriter.writeElementString("RespInfo", respInfo);
    }

    public void writeAfter() {
        writeEnd();
    }

    public void writeDetail(RetAtsB001OperBillQryDetail DB001Detail) {
        retXmlWriter.writeStartElement("DetailRecord");
        retXmlWriter.writeElementString("BillNo", DB001Detail.billNo);
        retXmlWriter.writeElementString("BillType", DB001Detail.billType);
        retXmlWriter.writeElementString("IssDate", DB001Detail.issDate);
        retXmlWriter.writeElementString("DueDate", DB001Detail.dueDate);
        retXmlWriter.writeElementString("BillAmt", DB001Detail.billAmt);

        retXmlWriter.writeElementString("TransFlag", DB001Detail.transFlag);
        retXmlWriter.writeElementString("MustPay", DB001Detail.mustPay);
        retXmlWriter.writeElementString("DrawName", DB001Detail.drawName);
        retXmlWriter.writeElementString("DrawCode", DB001Detail.drawCode);
        retXmlWriter.writeElementString("DrawAct", DB001Detail.drawAct);

        retXmlWriter.writeElementString("DrawBnkName", DB001Detail.drawBnkName);
        retXmlWriter.writeElementString("DrawBnkCode", DB001Detail.drawBnkCode);
        retXmlWriter.writeElementString("AccpName", DB001Detail.accpName);
        retXmlWriter.writeElementString("AccpCode", DB001Detail.accpCode);
        retXmlWriter.writeElementString("AccpAct", DB001Detail.accpAct);

        retXmlWriter.writeElementString("AccpBnkName", DB001Detail.accpBnkName);
        retXmlWriter.writeElementString("AccpBnkCode", DB001Detail.accpBnkCode);
        retXmlWriter.writeElementString("PayeeName", DB001Detail.payeeName);
        retXmlWriter.writeElementString("PayeeCode", DB001Detail.payeeCode);
        retXmlWriter.writeElementString("PayeeAct", DB001Detail.payeeAct);

        retXmlWriter.writeElementString("PayeeBnkName", DB001Detail.payeeBnkName);
        retXmlWriter.writeElementString("PayeeBnkCode", DB001Detail.payeeBnkCode);
        retXmlWriter.writeElementString("BusiNo", DB001Detail.busiNo);
        retXmlWriter.writeElementString("BusiType", DB001Detail.busiType);
        retXmlWriter.writeElementString("QueryType", DB001Detail.queryType);

        retXmlWriter.writeElementString("ApplyReq", DB001Detail.applyReq);
        retXmlWriter.writeElementString("ApplyDate", DB001Detail.applyDate);
        retXmlWriter.writeElementString("ApplyName", DB001Detail.applyName);
        retXmlWriter.writeElementString("ApplyCode", DB001Detail.applyCode);
        retXmlWriter.writeElementString("ApplyAct", DB001Detail.applyAct);

        retXmlWriter.writeElementString("ApplyBnkName", DB001Detail.applyBnkName);
        retXmlWriter.writeElementString("ApplyBnkCode", DB001Detail.applyBnkCode);
        retXmlWriter.writeElementString("ReceName", DB001Detail.receName);
        retXmlWriter.writeElementString("ReceCode", DB001Detail.receCode);
        retXmlWriter.writeElementString("ReceAct", DB001Detail.receAct);

        retXmlWriter.writeElementString("ReceBnkName", DB001Detail.receBnkName);
        retXmlWriter.writeElementString("ReceBnkCode", DB001Detail.receBnkCode);
        retXmlWriter.writeElementString("Memo", DB001Detail.memo);
        retXmlWriter.writeElementString("ContractNo", DB001Detail.contractNo);
        retXmlWriter.writeElementString("InvoiceNo", DB001Detail.invoiceNo);

        retXmlWriter.writeElementString("DiscType", DB001Detail.discType);
        retXmlWriter.writeElementString("PayType", DB001Detail.payType);
        retXmlWriter.writeElementString("RepOpenDate", DB001Detail.repOpenDate);
        retXmlWriter.writeElementString("RepDueDate", DB001Detail.repDueDate);
        retXmlWriter.writeElementString("DiscRate", DB001Detail.discRate);

        retXmlWriter.writeElementString("RepRate", DB001Detail.repRate);
        retXmlWriter.writeElementString("ActedAct", DB001Detail.actedAct);
        retXmlWriter.writeElementString("ActedBnkCode", DB001Detail.actedBnkCode);
        retXmlWriter.writeElementString("OverDueRea", DB001Detail.overDueRea);
        retXmlWriter.writeElementString("OverDueFlag", DB001Detail.overDueFlag);
        retXmlWriter.writeElementString("RecourseType", DB001Detail.recourseType);

        retXmlWriter.writeElementString("RecourseAmt", DB001Detail.recourseAmt);
        retXmlWriter.writeElementString("RecourseCode", DB001Detail.recourseCode);
        retXmlWriter.writeElementString("AccpDate",DB001Detail.accpDate);
        //票据状态不能返回为空，不然ats会报状态无法映射错误
        if(StringHelper.hasAnyChar(DB001Detail.billStatus)) {
            retXmlWriter.writeElementString("BillStatus", DB001Detail.billStatus);
        }else {
            retXmlWriter.writeElementString("BillStatus", "B0082");//票据状态待更新
        }
        retXmlWriter.writeEndElement();
    }

}
